package ddbtasktracker.dummy;

import tasktracker.abstraction.TaskInfo;
import tasktracker.abstraction.TaskProgressInfo;
import tasktracker.abstraction.TaskResultInfo;
import tasktracker.abstraction.TaskStatus;
import tasktracker.abstraction.extensions.ThreadedTaskTracker;

public class DummyTaskTracker extends ThreadedTaskTracker {

	@Override
	protected void doThreadedTask(TaskInfo task) throws InterruptedException {
		reportStatus(task.getGuid(), TaskStatus.RUNNING, null);

		TaskProgressInfo progressInfo = task.getProgress();
		progressInfo.clear();
		progressInfo.setTotalStagesCount(1);
		progressInfo.setCurrentStageCount(10);

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(1);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(2);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(3);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(4);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(5);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(6);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(7);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(8);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(9);
		progressInfo.report();

		Thread.sleep(1000);
		progressInfo.setCurrentStageCompleted(10);
		progressInfo.report();
		
		progressInfo.setTotalStagesCompleted(1);
		
		TaskResultInfo result = new TaskResultInfo();
		result.setPrimaryMessage("Dummy:Primary");
		result.setSecondaryMessage("Dummy:Secondary");
		reportStatus(task.getGuid(), TaskStatus.COMPLETED, result);
	}

}
